//
//  YBCloudComputerTableSecHeader.swift
//  Moonlight
//
//  Created by Penlon Kim on 2023/6/8.
//  Copyright © 2023 Moonlight Game Streaming Project. All rights reserved.
//

import UIKit
import SnapKit

class YBCloudComputerTableSecHeader: UITableViewHeaderFooterView {
    
    private var shapeLayer: CAShapeLayer = CAShapeLayer()
    
    override init(reuseIdentifier: String?) {
        super.init(reuseIdentifier: reuseIdentifier)
        
        self.backgroundColor = .lightWhiteDark33
        contentView.backgroundColor = .lightWhiteDark33
        contentView.layer.mask = shapeLayer
        
        contentView.addSubview(kTitleLabel)
        kTitleLabel.snp.makeConstraints { (make) in
            make.left.equalTo(20)
            make.top.equalTo(14)
            make.height.equalTo(20)
        }
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        let bezierPath = UIBezierPath(roundedRect: bounds, byRoundingCorners: [.topLeft, .topRight], cornerRadii: CGSize(width: 4, height: 4))
        shapeLayer.path = bezierPath.cgPath
    }
    
    /// 重写frame
    override var frame: CGRect {
        get { return super.frame }
        set {
            var frame = newValue
            frame.origin.x += 10
            frame.origin.y += 0
            frame.size.width -= 2*10
            frame.size.height -= 0
            super.frame = frame
        }
    }
    
    // MARK: - lazy
    lazy var kTitleLabel = self.bk_addLabel(font: .systemFont(ofSize: 14, weight: .semibold), bgColor: .clear, textColor: .lightBlack51DarkLight230)
    
}
